package com.example.peibei.ui.activity;

import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;

import com.dingtao.common.core.WDActivity;
import com.example.peibei.R;
import com.example.peibei.ui.fragment.MySendOrderListFragment;
import com.example.peibei.ui.fragment.MyWaitOrderListFragment;
import com.flyco.tablayout.SlidingTabLayout;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.OnClick;

public class MyWaitOrderActivity extends WDActivity {
    @BindView(R.id.slide_tablayout)
    SlidingTabLayout tabLayout;
    @BindView(R.id.viewpager)
    ViewPager viewpager;
    @BindView(R.id.tv_title)
    TextView tv_title;

    private String[] title={"待处理","进行中","已完成"};
    private ArrayList<Fragment> fragments=new ArrayList<>();

    @Override
    protected int getLayoutId() {
        return R.layout.activity_my_get_order;
    }

    @Override
    protected void initView() {
        tv_title.setText("接单");
        fragments.add(new MyWaitOrderListFragment(0));
        fragments.add(new MyWaitOrderListFragment(1));
        fragments.add(new MyWaitOrderListFragment(3));
        viewpager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @NonNull
            @Override
            public Fragment getItem(int position) {
                return fragments.get(position);
            }

            @Override
            public int getCount() {
                return fragments.size();
            }

            @Nullable
            @Override
            public CharSequence getPageTitle(int position) {
                return title[position];
            }
        });
        tabLayout.setViewPager(viewpager,title,this,fragments);
    }

    @OnClick(R.id.iv_back)
    public void back(){
        finish();
    }

    @Override
    protected void destoryData() {

    }
}
